<template xmlns:el-col="http://www.w3.org/1999/html">
  <el-container>
    <el-row class="wrap" v-loading="loading" element-loading-text="拼命加载中">
      <el-col :span="24" class="warp-breadcrum">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/dashboard' }"><span style="color: #837e7c;font-weight: normal;">首页</span></el-breadcrumb-item>
          <el-breadcrumb-item><span style="color: #837e7c;font-weight: normal;">联系人管理</span></el-breadcrumb-item>
          <el-breadcrumb-item><span style="color: #5d9cec;font-weight: normal;">黑名单管理</span></el-breadcrumb-item>
        </el-breadcrumb>
      </el-col>

      <el-col :span="24" class="wrap-main">
        <!--工具栏-->
        <el-col :span="24" class="gg-toolBar-wrap">
          <el-col :span="24" class="toolbar gg-toolBar">
            <el-form :inline="true" :model="formInline">
              <el-form-item>
                <el-input size="small" v-model="formInline.blackNum" placeholder="输入号码" style="min-width: 240px;"
                          @keyup.enter.native="handleSearch"></el-input>
              </el-form-item>
              <el-form-item prop="taskStartDate">
                <el-date-picker size="small" type="date" placeholder="请选择导入时间" v-model="formInline.blackImportTime" style="width:152px;"
                                @keyup.enter.native="handleSearch"></el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" size="small" icon="el-icon-search" @click="handleSearch">搜索</el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </el-col>
        <!--表格区域-->
        <el-col :span="24" class="gg-tableMainWrap">
          <!--导入号码-->
          <el-row class="gg-tableBtnWrap">
              <el-button size="small" icon="el-icon-close" style="float: left;">移除黑名单</el-button>
              <el-button type="primary" size="small" icon="el-icon-upload" style="float: right;" @click="openUpload()">导入号码</el-button>
          </el-row>
          <!--表格-->
          <el-row class="gg-tableWrap">
            <el-table :data="tableData" ref="multipleTable"  tooltip-effect="dark" border highlight-current-row
                      @selection-change="handleSelectionChange"
                      style="width: 100%;">
              <el-table-column
                type="selection"
                width="55"></el-table-column>
              <el-table-column prop="blackNum" label="号码">
              </el-table-column>
              <el-table-column prop="blackImportantTime" label="导入时间" sortable>
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button size="mini" type="danger" @click="remove(scope.$index,scope.row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-row>

          <!--分页插件-->
          <el-col :span="24" class="toolbar">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 50,100]"
              :page-size="10"
              layout="total, sizes, prev, pager, next, jumper"
              style="float:right;">
            </el-pagination>
          </el-col>
        </el-col>
      </el-col>
    </el-row>

    <el-dialog title="导入黑名单号码" :visible.sync="dialogFormVisible">
      <el-form :model="uploadForm">
        <el-form-item label="导入号码:" :label-width="formLabelWidth">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="3"
            :on-exceed="handleExceed">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传excel/csv文件，其他格式目前不支持</div>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormInnerVisible=true">确 定</el-button>
      </div>
      <el-dialog
        width="30%"
        title="操作提示"
        :visible.sync="dialogFormInnerVisible"
        append-to-body>
        <div>
          <ul>
            <li>
              <span>总号码数:2</span>
            </li>
            <li>
              <span>成功导入:2</span>
            </li>
            <li>
              <span>重复号码:无</span>
            </li>
          </ul>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormInnerVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible=false,dialogFormInnerVisible = false">确 定</el-button>
        </div>
      </el-dialog>
    </el-dialog>

  </el-container>
</template>

<script>
  export default {
    name: "ContactBlackList",
    data() {
      return {
        total: 0,
        page: 1,
        limit: 10,
        loading: false,
        formLabelWidth: '120px',
        dialogFormVisible:false,
        dialogFormInnerVisible:false,
        currentPage: 1,
        formInline: {
          blackNum: '',
          blackImportTime: '',
        },
        uploadForm:{},
        multipleSelection: [],
        tableData: [{
          blackNum: '13001010101',
          blackImportantTime:'2018-09-11 17:25:07'
        },{
          blackNum: '13001010102',
          blackImportantTime:'2018-09-21 17:25:07'
        }]
      }
    },
    methods: {
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
      handleSearch() {
        console.log('submit!');
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      openUpload:function(){
        this.dialogFormVisible = true;
      },
      addSubmit:function(groupName){
        let that = this;
        this.$refs[groupName].validate((valid)=>{
          if(valid){
            that.addUsersFormVisible = false;
          }
        })
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
      remove:function(index,row){
        let that = this;
        this.$confirm('确定要删除该条记录吗?','操作提示',{
          confirmButtonText:'确定',
          cancelButtonText:'取消',
          type:"warning"
        }).then(()=>{
          this.$message({
            type:'success',
            message:'删除成功!',
          })
        }).catch(()=>{
          this.$message({
            type:'info',
            message:'已取消删除'
          })
        })
      },
    }
  }
</script>

<style scoped>
  .el-tag {
    padding: 0px 8px;
    height: 25px;
    line-height: 25px;
    font-size: 11px;
    color: #fff;
    border-radius: 12px;
    box-sizing: border-box;
    border:none;
  }
</style>
